package com.tcp;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author weijingchen
 * @Date 2025/6/26 7:33
 * @Version 1.0.0
 */
public class TcpServer {
    public static void main(String[] args) throws IOException {
        ServerSocket socket = new ServerSocket(10010);
        Socket accept = socket.accept();
        InputStream inputStream = accept.getInputStream();
        //创建转换流
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        //创建缓冲流
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

        int b;
        while ((b = bufferedReader.read()) != -1) {
            System.out.print((char) b);
        }
        accept.close();
        socket.close();
        //字节流是通过socket创建的，socket关闭后，字节流也会关闭
    }
}
